﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PCMSofCC;

namespace PCMSofCC.BLL
{
    public static class AvailableTime
    {
        public static void UpdateTime(Guid _userId, WeekDay _flags, DateTime _date)
        {
            PCMSofCCDataContext db = new PCMSofCCDataContext();
            var t = db.AvailableDay.Single(x => x.UserId == _userId);
            t.SubmitDate = _date;
            t.AvailableDayFlag = (int)_flags;
            db.SubmitChanges();
        }

        public static void GetAvailableDayAndSubmitDate(Guid _userId, out int? flags, out DateTime? submitDate)
        {
            PCMSofCCDataContext db = new PCMSofCCDataContext();
            var q =
                from d in db.AvailableDay
                where d.UserId == _userId
                select d;
            flags = q.Single().AvailableDayFlag;
            submitDate = q.Single().SubmitDate;
        }
    }
}
